// 4.6. object
var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        if (typeof b !== "function" && b !== null)
            throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
// 限制⼀般对象
// 限制person对象的具体内容，使⽤【,】分隔，问号代表可选属性
var person;
// 限制car对象的具体内容，使⽤【;】分隔，必须有price和color属性，其他属性不去限制，有没有都⾏
var car;
// 限制student对象的具体内容，使⽤【回⻋】分隔
var student;
// 以下代码均⽆警告
car = {
    price: 10,
    brand: 'BMW',
    color: 'red',
};
// 限制函数的参数、返回值
var demo;
demo = function (a, b) {
    return a + b;
};
// 限制数组
var arr1; // 数字数组  等价于 let arr1: Array<number>;
var arr2; // 字符串数组  等价于 let arr2: Array<string>;
// 4.7. tuple
var t;
t = ['hello', 123];
// 4.8. enum
// 定义⼀个枚举
var Color;
(function (Color) {
    Color[Color["Red"] = 0] = "Red";
    Color[Color["Blue"] = 1] = "Blue";
    Color[Color["Black"] = 2] = "Black";
    Color[Color["Gold"] = 3] = "Gold";
})(Color || (Color = {}));
// console.log(Color);
// 定义⼀个枚举，并指定其初识数值
var Color2;
(function (Color2) {
    Color2[Color2["Red"] = 6] = "Red";
    Color2[Color2["Blue"] = 7] = "Blue";
    Color2[Color2["Black"] = 8] = "Black";
    Color2[Color2["Gold"] = 9] = "Gold";
})(Color2 || (Color2 = {}));
// console.log(Color2);
// 定义⼀个枚举，并将枚举成员指定字符串值
var Color3;
(function (Color3) {
    Color3["Red"] = "red";
    Color3["Blue"] = "blue";
    Color3["Black"] = "black";
    Color3["Gold"] = "gold";
})(Color3 || (Color3 = {}));
// console.log(Color2);
// 定义一个phone变量，并设置对齐进行限制
var phone;
phone = {
    name: 'iphone',
    price: 10,
    color: Color3.Red,
};
// console.log(phone);
if (phone.color === Color3.Red) {
    // console.log('手机是红色的');
}
// 5. 自定义类型
// 自定义类型，可以更灵活的限制类型
// 性别类型
var Gender;
(function (Gender) {
    Gender[Gender["Male"] = 0] = "Male";
    Gender[Gender["Female"] = 1] = "Female";
})(Gender || (Gender = {}));
// 定义两个学生变量： s1 和 s2
var s1;
var s2;
s1 = {
    name: '张三',
    age: 20,
    gender: Gender.Male,
    grade: 3,
};
s2 = {
    name: '李四',
    gender: Gender.Female,
    grade: 2,
};
// 6. 抽象类
// 常规类
var Person = /** @class */ (function () {
    function Person(name, age) {
        this.name = name;
        this.age = age;
    }
    return Person;
}());
var p1 = new Person('张三', 20);
var p2 = new Person('李四', 30);
// 继承
var Teacher = /** @class */ (function (_super) {
    __extends(Teacher, _super);
    function Teacher(name, age) {
        return _super.call(this, name, age) || this;
    }
    return Teacher;
}(Person));
// 抽象类：不能实例化，只能被继承，抽象类里有抽象方法
var Animal = /** @class */ (function () {
    function Animal(name) {
        this.name = name;
    }
    return Animal;
}());
// Doctor实现Career接口
var Doctor = /** @class */ (function () {
    function Doctor(name, desc) {
        this.jobName = name;
        this.jobDesc = desc;
    }
    Doctor.prototype.work = function () {
        // console.log('医生工作，需要做的事情是', this.jobDesc);
    };
    return Doctor;
}());
// Engineer类继承PersonInter
var Enginneer = /** @class */ (function () {
    function Enginneer(name, age) {
        this.name = name;
        this.age = age;
    }
    Enginneer.prototype.work = function () {
        // console.log('工程师工作，需要做的事情是', '写代码');
    };
    return Enginneer;
}());
// 3. 接口与自定义类型的区别
// 接口可以：
// 1. 可以当自定义类型使用
// 2. 可以限制类的结构
// 9. 泛型
// 定义一个函数或类时，有些行
